package com.example.xm.ui.home.fragments.activity_article;

import android.os.Bundle;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.example.xm.R;
import com.example.xm.adapter.HomeAdapter.Article_RenShiAdapter;
import com.example.xm.base.BaseActivity;
import com.example.xm.bean.HomeBean.HomeArticleChuanTongBean;
import com.example.xm.bean.HomeBean.HomeArticleDaShiJianBean;
import com.example.xm.bean.HomeBean.HomeArticleRenShiBean;
import com.example.xm.bean.HomeBean.HomeArticleYanJinBean;
import com.example.xm.interfaces.home.IArticle;
import com.example.xm.presenter.home.ArticlePresenter;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class Article_RenShiActivity extends BaseActivity<IArticle.ArticlePresenter> implements IArticle.ArticleView {

    @BindView(R.id.rlv_renshi)
    RecyclerView rlvRenshi;
    private Article_RenShiAdapter article_renShiAdapter;
    private ArrayList<HomeArticleRenShiBean.DataBean> dataBeans;
    private ArrayList<HomeArticleRenShiBean.DataBean> list;

    @Override
    protected IArticle.ArticlePresenter initPresenter() {
        return new ArticlePresenter();
    }

    @Override
    protected int getLayout() {
        return R.layout.activity_article_ren_shi;
    }

    @Override
    protected void initView() {
        list = dataBeans = new ArrayList<>();
        rlvRenshi.setLayoutManager(new LinearLayoutManager(this));
        article_renShiAdapter = new Article_RenShiAdapter(this, list);
        rlvRenshi.setAdapter(article_renShiAdapter);
    }

    @Override
    protected void initData() {
        mPresenter.getRenShi();
    }

    @Override
    protected void initListener() {

    }

    @Override
    public void getRenShiResult(HomeArticleRenShiBean result) {
        if (result.getStatus().getStatusCode() == 100) {
            List<HomeArticleRenShiBean.DataBean> data = result.getData();
            list.addAll(data);
            article_renShiAdapter.notifyDataSetChanged();
        }
    }

    @Override
    public void getChuanTongResult(HomeArticleChuanTongBean result) {

    }

    @Override
    public void getYanJinResult(HomeArticleYanJinBean result) {

    }

    @Override
    public void getDaShiJianResult(HomeArticleDaShiJianBean result) {

    }

    @Override
    public void showTips(String tips) {

    }

    @Override
    public void showLoading(int visble) {

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }
}